Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to keep original rotate page in itextSharp (dll)
    primarykey
    data
    text
    <p>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, and next cell have info what write on the top in second pdf. </p> <p>And problem is here, original pdf is horizontal, landscape, rotate and my program create copy from original pdf and write info from excel on the top on copy pdf file. But pdf which is landscape is rotate for 270 deegres. This is no OK. For portrait rotation working program OK, copy OK and write on the top of the copy is OK. Where is my problem in my code. </p> <p>Code: </p> <pre><code>public int urediPDF(string inTekst) { if (inTekst != "0") { string pisava_arialBD = @"..\debug\arial.ttf"; string oldFile = null; string inText = null; string indeks = null; //razbitje stringa string[] vhod = inTekst.Split('#'); oldFile = vhod[0]; inText = vhod[1]; indeks = vhod[2]; string newFile = @"c:\da\2"; //odpre bralnik pdf PdfReader reader = new PdfReader(oldFile); Rectangle size = reader.GetPageSizeWithRotation(reader.NumberOfPages); Document document = new Document(size); //odpre zapisovalnik pdf FileStream fs = new FileStream(newFile + "-" + indeks + ".pdf", FileMode.Create, FileAccess.Write); PdfWriter writer = PdfWriter.GetInstance(document, fs); //document.Open(); document.OpenDocument(); label2.Text = ("Status: " + reader.GetPageRotation(reader.NumberOfPages).ToString()); //določi sejo ustvarjanje pdf PdfContentByte cb = writer.DirectContent; //izbira pisave oblike BaseFont bf = BaseFont.CreateFont(pisava_arialBD, BaseFont.IDENTITY_H, BaseFont.NOT_EMBEDDED); cb.SetColorFill(BaseColor.RED); cb.SetFontAndSize(bf, 8); //pisanje teksta v pdf cb.BeginText(); string text = inText; //izbira koordinat za zapis pravilnega teksta v pdf (720 stopinj roatacija (ležeče) in 90 stopinj (pokončno)) if (reader.GetPageRotation(1) == 720) //ležeča postavitev { cb.ShowTextAligned(1, text, 10, 450, 0); cb.EndText(); } else //pokončna postavitev { cb.ShowTextAligned(1, text + " - pokončen", 10, 750, 0); cb.EndText(); } // create the new page and add it to the pdf PdfImportedPage page = writer.GetImportedPage(reader, reader.NumberOfPages); cb.AddTemplate(page, 0, 0); // close the streams and voilá the file should be changed :) document.Close(); fs.Close(); writer.Close(); reader.Close(); } else { label2.Text = "Status: Končano zapisovanje"; return 0; } return 0; } </code></pre> <p>Picture fake pdf: </p> <p><img src="https://i.stack.imgur.com/phePr.png" alt="Fake PDF"></p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload