Click here to Skip to main content
15,896,348 members
Home / Discussions / C#
   

C#

 
AnswerRe: List Pin
Dave Kreskowiak25-Jul-14 2:24
mveDave Kreskowiak25-Jul-14 2:24 
GeneralRe: List Pin
Mycroft Holmes25-Jul-14 14:20
professionalMycroft Holmes25-Jul-14 14:20 
GeneralRe: List Pin
Dave Kreskowiak26-Jul-14 3:53
mveDave Kreskowiak26-Jul-14 3:53 
AnswerRe: List Pin
GuyThiebaut25-Jul-14 3:06
professionalGuyThiebaut25-Jul-14 3:06 
GeneralRe: List Pin
Mycroft Holmes25-Jul-14 14:25
professionalMycroft Holmes25-Jul-14 14:25 
GeneralRe: List Pin
GuyThiebaut25-Jul-14 19:18
professionalGuyThiebaut25-Jul-14 19:18 
AnswerRe: List Pin
Steve Foutty25-Jul-14 3:12
Steve Foutty25-Jul-14 3:12 
GeneralRe: List Pin
PIEBALDconsult25-Jul-14 20:27
mvePIEBALDconsult25-Jul-14 20:27 
QuestionAsp.net rdcl Report Pin
Zeyad Jalil23-Jul-14 23:00
professionalZeyad Jalil23-Jul-14 23:00 
AnswerRe: Asp.net rdcl Report Pin
thatraja24-Jul-14 2:17
professionalthatraja24-Jul-14 2:17 
QuestionCrystal Report Sort by Date Formula Pin
Amr Muhammed23-Jul-14 13:28
Amr Muhammed23-Jul-14 13:28 
AnswerRe: Crystal Report Sort by Date Formula Pin
thatraja24-Jul-14 2:30
professionalthatraja24-Jul-14 2:30 
AnswerRe: Crystal Report Sort by Date Formula Pin
jschell24-Jul-14 11:39
jschell24-Jul-14 11:39 
QuestionUsing a proxy server in c# Pin
Member 1052179323-Jul-14 13:03
Member 1052179323-Jul-14 13:03 
AnswerRe: Using a proxy server in c# Pin
Bernhard Hiller23-Jul-14 20:23
Bernhard Hiller23-Jul-14 20:23 
GeneralRe: Using a proxy server in c# Pin
Member 1052179324-Jul-14 0:53
Member 1052179324-Jul-14 0:53 
GeneralRe: Using a proxy server in c# Pin
Bernhard Hiller24-Jul-14 2:58
Bernhard Hiller24-Jul-14 2:58 
QuestionKurti dev to uni code and uni code yo kurti dev convert by script Pin
Member 1096585923-Jul-14 1:36
Member 1096585923-Jul-14 1:36 
AnswerRe: Kurti dev to uni code and uni code yo kurti dev convert by script Pin
thatraja23-Jul-14 1:57
professionalthatraja23-Jul-14 1:57 
GeneralRe: Kurti dev to uni code and uni code yo kurti dev convert by script Pin
Member 1096585923-Jul-14 2:03
Member 1096585923-Jul-14 2:03 
GeneralRe: Kurti dev to uni code and uni code yo kurti dev convert by script Pin
thatraja23-Jul-14 21:07
professionalthatraja23-Jul-14 21:07 
QuestioniTextSharp PDF Overlay Pin
michPla1223-Jul-14 1:16
michPla1223-Jul-14 1:16 
Hello,

I am asking myself for a couple of hours how I can work around the following problem.

It seems that I need to create my PDF by using "Document" instead of PdfStamper to get the size and rotation. But there are two problems I have with this.
- The Opacity seems not to work (Docu //Overlay Transperency)
- I can't figure out how I can decide if the overlay is in background or foreground.
With
C#
PdfContentByte cb1 = outputWriter.DirectContent;
it seems always to be in the foreground. I can also create the PdfContentByte with
C#
PdfContentByte cb1 = outputWriter.DirectContentUnder;

but I can't figure out how I can do something like this ...
C#
if (<condition>)
  PdfContentByte cb1 = outputWriter.DirectContentUnder;
else
  PdfContentByte cb1 = outputWriter.DirectContent; 



This is my code.

C#
string TempFileName = "";

TempFileName = Path.GetTempFileName();

FilePdfReader = new PdfReader(FileMemoryStream);
Document inputDoc = new Document(FilePdfReader.GetPageSizeWithRotation(1));





using (FileStream fs = new FileStream(TempFileName, FileMode.Create))
{
    //Create the PDF Writer to create the new PDF Document
    PdfWriter outputWriter = PdfWriter.GetInstance(inputDoc,fs);

    inputDoc.Open();


    //Create the Content Byte to stamp to the writer
    PdfContentByte cb1 = outputWriter.DirectContent;

    //Get the PDF document to use as overlay
    PdfReader overlayReader = new PdfReader(OverlayMemoryStream);
    PdfImportedPage overLay = outputWriter.GetImportedPage(overlayReader, 1);

    PdfGState GState = new PdfGState();

    //Get the overlay page rotation
    int overlayRotation = overlayReader.GetPageRotation(1);

    int n = FilePdfReader.NumberOfPages;

    int i = 1;
    while (i <= n)
    {
        //Make sure the new page's page size macthes the original document
        inputDoc.SetPageSize(FilePdfReader.GetPageSizeWithRotation(i));
        inputDoc.NewPage();


        PdfImportedPage page = outputWriter.GetImportedPage(FilePdfReader, i);
        int rotation = FilePdfReader.GetPageRotation(i);


        //Overlay Transperency
        if ( (OverlayFillOpacity != 0f) || (OverlayStrokeOpacity != 0f) )
        {
            GState.FillOpacity = OverlayFillOpacity;
            GState.StrokeOpacity = OverlayStrokeOpacity;

            cb1.SaveState();
            cb1.SetGState(GState);
        }


        //Insert the overlay with correct rotation
        if (overlayRotation == 90 || overlayRotation == 270)
        {
            cb1.AddTemplate(overLay, 0, -1f, 1f, 0, 0,
                FilePdfReader.GetPageSizeWithRotation(i).Height);
        }
        else
        {
            cb1.AddTemplate(overLay, 1f, 0, 0, 1f, 0, 0);
        }

        //Insert the original PDF page with correct rotation
        if (rotation == 90 || rotation == 270)
        {
            cb1.AddTemplate(page, 0, -1f, 1f, 0, 0,
                FilePdfReader.GetPageSizeWithRotation(i).Height);
        }
        else
        {
            cb1.AddTemplate(page, 1f, 0, 0, 1f, 0, 0);
        }

        //Increment the page
        i++;
    }

    //Close the input file
    inputDoc.Close();
    //Close the reader for the overlay file
    overlayReader.Close();

Questionadd multiple passengers Pin
Jassim Rahma22-Jul-14 11:41
Jassim Rahma22-Jul-14 11:41 
GeneralRe: add multiple passengers Pin
PIEBALDconsult22-Jul-14 18:58
mvePIEBALDconsult22-Jul-14 18:58 
AnswerRe: add multiple passengers Pin
OriginalGriff22-Jul-14 19:47
mveOriginalGriff22-Jul-14 19:47 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.