Ho un problema con riguardo all'orientamento della pagina del formato della carta.
Ho un file pdf che contiene portrait e pagina panoramica.Impostazione della posizione dell'immagine utilizzando iTextSharp
questo codice funziona perfettamente.
string FileLocation = "c:\\Temp\\SomeFile.pdf";
string WatermarkLocation = "c:\\Temp\\watermark.gif";
Document document = new Document();
PdfReader pdfReader = new PdfReader(FileLocation);
PdfStamper stamp = new PdfStamper(pdfReader, new FileStream(FileLocation.Replace(".pdf","[temp][file].pdf"), FileMode.Create));
iTextSharp.text.Image img = iTextSharp.text.Image.GetInstance(WatermarkLocation);
img.SetAbsolutePosition(250,300); // set the position in the document where you want the watermark to appear (0,0 = bottom left corner of the page)
PdfContentByte waterMark;
for (int page = 1; page <= pdfReader.NumberOfPages; page++)
{
waterMark = stamp.GetUnderContent(page);
waterMark.AddImage(img);
}
stamp.FormFlattening = true;
stamp.Close();
// now delete the original file and rename the temp file to the original file
File.Delete(FileLocation);
File.Move(FileLocation.Replace(".pdf", "[temp][file].pdf"), FileLocation);
dal momento che sto usando valore assoluto per impostare la posizione dell'immagine.
img.SetAbsolutePosition(250,300);
Come può T impostare la posizione dell'immagine se la pagina è orizzontale o verticale?
note: un pdf con orientamento orizzontale e verticale.
C'è un caso che posso usare se dichiarazione?
if (//paper is landscape)
{
//code here
}
else
{
//code here
}