logo
down
shadow

Add 'PageSetupAccessory' to PrintPanel for PDFDocument


Add 'PageSetupAccessory' to PrintPanel for PDFDocument

By : user3100732
Date : January 12 2021, 09:11 PM
around this issue Based on @Willeke's comments, I've come up with the following, which seems to work well. (Minor quibble is that the Print dialog isn't a sheet.) If anyone has any improvements, please post a better answer.
code :
@IBAction func printContent(_ sender: Any) {
   let printOperation = thePDFView.document?.printOperation(for: thePrintInfo(), scalingMode: .pageScaleNone, autoRotate: true)
printOperation?.printPanel = thePrintPanel()
printOperation?.run()
}


Share : facebook icon twitter icon
Itextsharp PdfDocument or PdfDocument from It.Document

Itextsharp PdfDocument or PdfDocument from It.Document


By : Tom
Date : March 29 2020, 07:55 AM
should help you out I am adding page numbers to the bottom of a pdf document using ITextSharp The thing is, it is made up of 4 or 5 different PDF's that are combined through the process, and there are some dynamically added pages so the PDF can vary in size. I cannot call document.PageCount because it "lacks the get accessor". , Found it guys :D
So whenever you make your writer:
code :
using (MemoryStream MS = new MemoryStream())
        {
            PdfWriter writer = PdfWriter.GetInstance(doc, MS);
            writer.ViewerPreferences = PdfWriter.PageModeUseOutlines;
            PdfFooter eventHandler = new PdfFooter();
            writer.PageEvent = eventHandler;

ect.
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using iTextSharp.text.pdf;
using iTextSharp.text;

public class PdfFooter : PdfPageEventHelper
{
    // This is the contentbyte object of the writer
    PdfContentByte cb;

// we will put the final number of pages in a template
PdfTemplate template;

// this is the BaseFont we are going to use for the header / footer
BaseFont bf = null;

// This keeps track of the creation time
DateTime PrintTime = DateTime.Now;

#region Properties
private string _Title;
public string Title
{
    get { return _Title; }
    set { _Title = value; }
}

private string _HeaderLeft;
public string HeaderLeft
{
    get { return _HeaderLeft; }
    set { _HeaderLeft = value; }
}

private string _HeaderRight;
public string HeaderRight
{
    get { return _HeaderRight; }
    set { _HeaderRight = value; }
}

private Font _HeaderFont;
public Font HeaderFont
{
    get { return _HeaderFont; }
    set { _HeaderFont = value; }
}

private Font _FooterFont;
public Font FooterFont
{
    get { return _FooterFont; }
    set { _FooterFont = value; }
}
#endregion

// we override the onOpenDocument method
public override void OnOpenDocument(PdfWriter writer, Document document)
{
    try
    {
        PrintTime = DateTime.Now;
        bf = BaseFont.CreateFont(BaseFont.HELVETICA, BaseFont.CP1252, BaseFont.NOT_EMBEDDED);
        cb = writer.DirectContent;
        template = cb.CreateTemplate(50, 50);
    }
    catch (DocumentException de)
    {
    }
    catch (System.IO.IOException ioe)
    {
    }
}

public override void OnEndPage(PdfWriter writer, Document document)
{
    base.OnEndPage(writer, document);

    int pageN = writer.PageNumber;
    String text = "Page " + pageN + " of ";
    float len = bf.GetWidthPoint(text, 8);

    Rectangle pageSize = document.PageSize;

    cb.SetRGBColorFill(100, 100, 100);

    cb.BeginText();
    cb.SetFontAndSize(bf, 8);
    cb.SetTextMatrix(pageSize.GetRight(70), pageSize.GetBottom(15));
    cb.ShowText(text);
    cb.EndText();

    cb.AddTemplate(template, pageSize.GetRight(70) + len, pageSize.GetBottom(15));
}

public override void OnCloseDocument(PdfWriter writer, Document document)
{
    base.OnCloseDocument(writer, document);

    template.BeginText();
    template.SetFontAndSize(bf, 8);
    template.SetTextMatrix(0, 0);
    template.ShowText("" + (writer.PageNumber - 1));
    template.EndText();
}
How to copy one page of a PDFDocument , to another PDFDocument

How to copy one page of a PDFDocument , to another PDFDocument


By : Jay K
Date : March 29 2020, 07:55 AM
may help you . A page in a PDF has many relations to other objects in a PDF.
If you could add a page located in one document to another one, the page would reside in both documents. Thus, the page suddenly would have to have all those relations to objects in both documents. This obviously does not work, thus iText prevents this.
code :
PdfDocument pdfWithMultiplePages = here I have a PDF with 3 pages.
....
PdfDocument pdfDocument = new PdfDocument(pdfWriter);
pdfDocument.copyPagesTo(i+1, i+1,pdfWithMultiplePages);
pdfWithMultiplePages.copyPagesTo(i+1, i+1, pdfDocument);
How to merge List<PdfDocument> into a single PdfDocument

How to merge List<PdfDocument> into a single PdfDocument


By : Ernesto
Date : March 29 2020, 07:55 AM
I hope this helps . I have a List with multiple PDFs , and I want to merge all of them into a single PdfDocument (im using iText) , and then transform this PdfDocument into a ByteArrayOutputStream (OR a byte[]).
code :
public byte[] mergePdfDocumentsIntoAPdfDocument(List<PdfDocument> pdfDocuments){
    ByteArrayOutputStream mergedPdfStream = new ByteArrayOutputStream();
    PdfDocument resultDoc = new PdfDocument(new PdfWriter(mergedPdfStream));

    for (PdfDocument doc : pdfDocuments) {
        int n = doc.getNumberOfPages();
        for (int i = 1; i <= n; i++) {
            PdfPage page = doc.getPage(i).copyTo(resultDoc);
            resultDoc.addPage(page);
        }
    }

    resultDoc.close();
    return mergedPdfStream.toByteArray();
}
Cocoa osx PDFView NSPrintOperation PrintPanel not showing page preview

Cocoa osx PDFView NSPrintOperation PrintPanel not showing page preview


By : Bowen Noack
Date : March 29 2020, 07:55 AM
I wish did fix the issue. From this link:
Html to PDF using PdfDocument

Html to PDF using PdfDocument


By : nidhi patel
Date : March 29 2020, 07:55 AM
hope this fix your issue This class does what you are looking for.
But to compile, it must be in package ".../java/android/print/"
Related Posts Related Posts :
  • I want to display two nodes overlapping each other with ARKit
  • Run Kitura Docker Image causes libmysqlclient.so.18 Error
  • How would you switch through kCL error in Swift?
  • How should I use this Github project properly?
  • How does my teacher know how many parameters to put in her closures and how does she know what type Swift will infer?
  • Custom Index for Linked List in Swift
  • Swift WKWebView continuous spell checking
  • Swift - Merging 2 arrays of objects with a key
  • Change frame of Live View in Swift playgrounds
  • Swift: Maintaining atomicity in a block-based execution using weak self
  • Why memory address is not changed for different instances of struct?
  • Filling a List in SwiftUI with CoreData
  • Kotlin Property Initialization (Like swift using closures)
  • Call a function from a separate class not working
  • Explanation of zip, reduce and combine in Swift
  • How to add a delay between loops when playing a tone in AVAudioPlayer?
  • How to add storyboard canvas orientation in git ignore in Xcode
  • How to execute different implementation of a method of a generic struct based on the generic type?
  • How to handle Errors on never ending chain with materialize?
  • RxSwift convert Observable<String> into String
  • Alamofire sending a request to an API 'NSInvalidArgumentException'
  • SwiftUI Conditional List - Unable to infer complex closure return type
  • Result values in '? :' expression have mismatching types 'String.SubSequence' (aka 'Substring') and 'String'
  • SwiftUI - Align contents of Button to the left
  • Swift handle did select on multiple annotations on same location
  • How to use NSPredicate for whether a List of Int contains a Int number?
  • SetNeedsDisplay having no effect
  • Can't initialize class with "if"
  • SKPaymentQueue.default().add(payment) ignored
  • How to share UIImage to Camera Roll using UIActivityViewController
  • Play Sound From String Arrays Swift
  • Runtime error using Combine: dyld: Symbol not found: _$s7Combine9PublishedV9PublisherCyx_GAadAMc
  • addPeriodicTimeObserver generate a escaping closure error
  • Since iOS 13 Beta 3, my app only displays a black window
  • showing uiview controller as a pop up
  • SwiftUI Beta 3 Black Screen
  • What is Content in SwiftUI?
  • How do I access the underlying key of a SymmetricKey in CryptoKit?
  • How to get dynamic Text height for a ScrollView with SwiftUI
  • SwiftUI: NavigationButton initializer gives error
  • How to limit character for username in Swift
  • How do I use UserDefaults with SwiftUI?
  • I'm an absolute beginner in swift. I don't what's wrong with the output of my code, This is based on mutating methods
  • How to reload data in UITableView when popping view controller
  • Cannot hook into another RxSwift stream based on a check
  • SwiftUI Change View with Button
  • SwiftUI: How to draw filled and stroked shape?
  • How to access inner object's properties from superclass without boilerplate
  • SwiftUI Table Custom Swipe?
  • Unwrapping optional inside map closure in Swift
  • What is the best way to wrap `purchaserInfo` for easy comparisons throughout your code using RevenueCat
  • How to shuffle multidimensional array?
  • Can you use a Publisher directly as an @ObjectBinding property in SwiftUI?
  • Changing certain words' colour in SCNText
  • Limit frequency with which firestore retrieves data
  • SwiftUI - Half modal?
  • Call a function multiple times and get a list of results in swift?
  • Open multiple preview same time in SwiftUI
  • What is simdTransform in SceneKit and ARKit?
  • How can I fill only part of the custom UIView rectangle?
  • shadow
    Privacy Policy - Terms - Contact Us © festivalmusicasacra.org