How to keep original rotate page in itextSharp (dll)

后端 未结 1 358
猫巷女王i
猫巷女王i 2021-01-25 02:59

i would like create the project, reading from Excel and write on pdf and print this pdf. From Excel file (from cell) read directory where is original pdf on computer or server,

1条回答
  •  囚心锁ツ
    2021-01-25 03:44

    As explained many times before (ITextSharp include all pages from the input file, Itext pdf Merge : Document overflow outside pdf (Text truncated) page and not displaying, and so on), you should read chapter 6 of my book iText in Action (you can find the C# version of the examples here).

    You are using a combination of Document, PdfWriter and PdfImportedPage to split a PDF. Please tell me who made you do it this way, so that I can curse the person who inspired you (because I've answered this question hundreds of times before, and I'm getting tired of repeating myself). These classes aren't a good choice for that job:

    • you lose all interactivity,
    • you need to rotate the content yourself if the page is in landscape,
    • you need to take the original page size into account,
    • ...

    Your problem is similar to this one itextsharp: unexpected elements on copied pages. Is there any reason why you didn't read the documentation? If you say: "I didn't have the time", please believe me if I say that I have almost 20 years of experience as a developer, and I've never seen "reading documentation" as a waste of time.

    Long story short: read the documentation, replace PdfWriter with PdfCopy, replace AddTemplate() with AddPage().

    0 讨论(0)
提交回复
热议问题