<?xml version="1.0"?>
<ownershipDocument>

    <schemaVersion>X0303</schemaVersion>

    <documentType>5</documentType>

    <periodOfReport>2009-12-31</periodOfReport>

    <form3HoldingsReported>0</form3HoldingsReported>

    <form4TransactionsReported>0</form4TransactionsReported>

    <issuer>
        <issuerCik>0000102212</issuerCik>
        <issuerName>UNIVEST CORP OF PENNSYLVANIA</issuerName>
        <issuerTradingSymbol>UVSP</issuerTradingSymbol>
    </issuer>

    <reportingOwner>
        <reportingOwnerId>
            <rptOwnerCik>0001415199</rptOwnerCik>
            <rptOwnerName>SCHWEITZER JEFFREY M</rptOwnerName>
        </reportingOwnerId>
        <reportingOwnerAddress>
            <rptOwnerStreet1>3964 GOSHEN DRIVE</rptOwnerStreet1>
            <rptOwnerStreet2></rptOwnerStreet2>
            <rptOwnerCity>HARLEYSVILLE</rptOwnerCity>
            <rptOwnerState>PA</rptOwnerState>
            <rptOwnerZipCode>19438</rptOwnerZipCode>
            <rptOwnerStateDescription></rptOwnerStateDescription>
        </reportingOwnerAddress>
        <reportingOwnerRelationship>
            <isDirector>0</isDirector>
            <isOfficer>1</isOfficer>
            <isTenPercentOwner>0</isTenPercentOwner>
            <isOther>0</isOther>
            <officerTitle>EVP &amp; CFO</officerTitle>
        </reportingOwnerRelationship>
    </reportingOwner>

    <nonDerivativeTable>
        <nonDerivativeHolding>
            <securityTitle>
                <value>COMMON</value>
            </securityTitle>
            <postTransactionAmounts>
                <sharesOwnedFollowingTransaction>
                    <value>4756.4529</value>
                    <footnoteId id="F1"/>
                    <footnoteId id="F2"/>
                </sharesOwnedFollowingTransaction>
            </postTransactionAmounts>
            <ownershipNature>
                <directOrIndirectOwnership>
                    <value>D</value>
                </directOrIndirectOwnership>
                <natureOfOwnership>
                    <value></value>
                </natureOfOwnership>
            </ownershipNature>
        </nonDerivativeHolding>
    </nonDerivativeTable>

    <derivativeTable>
        <derivativeHolding>
            <securityTitle>
                <value>STOCK OPTIONS</value>
            </securityTitle>
            <conversionOrExercisePrice>
                <value>21.11</value>
            </conversionOrExercisePrice>
            <exerciseDate>
                <value>2009-12-31</value>
            </exerciseDate>
            <expirationDate>
                <value>2017-12-31</value>
            </expirationDate>
            <underlyingSecurity>
                <underlyingSecurityTitle>
                    <value>COMMON</value>
                </underlyingSecurityTitle>
                <underlyingSecurityShares>
                    <value>6000</value>
                </underlyingSecurityShares>
            </underlyingSecurity>
            <postTransactionAmounts>
                <sharesOwnedFollowingTransaction>
                    <value>6000</value>
                </sharesOwnedFollowingTransaction>
            </postTransactionAmounts>
            <ownershipNature>
                <directOrIndirectOwnership>
                    <value>D</value>
                </directOrIndirectOwnership>
                <natureOfOwnership>
                    <value></value>
                </natureOfOwnership>
            </ownershipNature>
        </derivativeHolding>
        <derivativeHolding>
            <securityTitle>
                <value>STOCK OPTIONS</value>
            </securityTitle>
            <conversionOrExercisePrice>
                <value>17.53</value>
            </conversionOrExercisePrice>
            <exerciseDate>
                <value>2009-12-31</value>
            </exerciseDate>
            <expirationDate>
                <value>2017-12-31</value>
            </expirationDate>
            <underlyingSecurity>
                <underlyingSecurityTitle>
                    <value>COMMON</value>
                </underlyingSecurityTitle>
                <underlyingSecurityShares>
                    <value>1000</value>
                </underlyingSecurityShares>
            </underlyingSecurity>
            <postTransactionAmounts>
                <sharesOwnedFollowingTransaction>
                    <value>1000</value>
                    <footnoteId id="F3"/>
                </sharesOwnedFollowingTransaction>
            </postTransactionAmounts>
            <ownershipNature>
                <directOrIndirectOwnership>
                    <value>D</value>
                </directOrIndirectOwnership>
                <natureOfOwnership>
                    <value></value>
                </natureOfOwnership>
            </ownershipNature>
        </derivativeHolding>
        <derivativeHolding>
            <securityTitle>
                <value>STOCK OPTIONS</value>
            </securityTitle>
            <conversionOrExercisePrice>
                <value>22.90</value>
            </conversionOrExercisePrice>
            <exerciseDate>
                <value>2010-01-31</value>
            </exerciseDate>
            <expirationDate>
                <value>2018-01-31</value>
            </expirationDate>
            <underlyingSecurity>
                <underlyingSecurityTitle>
                    <value>COMMON</value>
                </underlyingSecurityTitle>
                <underlyingSecurityShares>
                    <value>126</value>
                </underlyingSecurityShares>
            </underlyingSecurity>
            <postTransactionAmounts>
                <sharesOwnedFollowingTransaction>
                    <value>126</value>
                    <footnoteId id="F4"/>
                </sharesOwnedFollowingTransaction>
            </postTransactionAmounts>
            <ownershipNature>
                <directOrIndirectOwnership>
                    <value>D</value>
                </directOrIndirectOwnership>
                <natureOfOwnership>
                    <value></value>
                </natureOfOwnership>
            </ownershipNature>
        </derivativeHolding>
        <derivativeHolding>
            <securityTitle>
                <value>STOCK OPTIONS</value>
            </securityTitle>
            <conversionOrExercisePrice>
                <value>22.90</value>
            </conversionOrExercisePrice>
            <exerciseDate>
                <value>2011-01-31</value>
            </exerciseDate>
            <expirationDate>
                <value>2019-01-31</value>
            </expirationDate>
            <underlyingSecurity>
                <underlyingSecurityTitle>
                    <value>COMMON</value>
                </underlyingSecurityTitle>
                <underlyingSecurityShares>
                    <value>2250</value>
                </underlyingSecurityShares>
            </underlyingSecurity>
            <postTransactionAmounts>
                <sharesOwnedFollowingTransaction>
                    <value>2250</value>
                    <footnoteId id="F5"/>
                </sharesOwnedFollowingTransaction>
            </postTransactionAmounts>
            <ownershipNature>
                <directOrIndirectOwnership>
                    <value>D</value>
                </directOrIndirectOwnership>
                <natureOfOwnership>
                    <value></value>
                </natureOfOwnership>
            </ownershipNature>
        </derivativeHolding>
        <derivativeHolding>
            <securityTitle>
                <value>STOCK OPTIONS</value>
            </securityTitle>
            <conversionOrExercisePrice>
                <value>24.40</value>
            </conversionOrExercisePrice>
            <exerciseDate>
                <value>2011-02-02</value>
            </exerciseDate>
            <expirationDate>
                <value>2019-02-02</value>
            </expirationDate>
            <underlyingSecurity>
                <underlyingSecurityTitle>
                    <value>COMMON</value>
                </underlyingSecurityTitle>
                <underlyingSecurityShares>
                    <value>327</value>
                </underlyingSecurityShares>
            </underlyingSecurity>
            <postTransactionAmounts>
                <sharesOwnedFollowingTransaction>
                    <value>327</value>
                    <footnoteId id="F6"/>
                </sharesOwnedFollowingTransaction>
            </postTransactionAmounts>
            <ownershipNature>
                <directOrIndirectOwnership>
                    <value>D</value>
                </directOrIndirectOwnership>
                <natureOfOwnership>
                    <value></value>
                </natureOfOwnership>
            </ownershipNature>
        </derivativeHolding>
    </derivativeTable>

    <footnotes>
        <footnote id="F1">DOES INCLUDE 600.4529 SHARES ACQUIRED ON OR AFTER AUGUST 15, 1996 THROUGH THE DIVIDEND REINVESTMENT PLAN AND EMPLOYEE STOCK PURCHASE PLAN.</footnote>
        <footnote id="F2">DOES INCLUDE 3,010 SHARES OF RESTRICTED STOCK.</footnote>
        <footnote id="F3">DOES INCLUDE 333 SHARES OF RESTRICTED STOCK.</footnote>
        <footnote id="F4">DOES INCLUDE 100 SHARES OF RESTRICTED STOCK.</footnote>
        <footnote id="F5">DOES INCLUDE 2,250 SHARES OF RESTRICTED STOCK.</footnote>
        <footnote id="F6">DOES INCLUDE 327 SHARES OF RESTRICTED STOCK.</footnote>
    </footnotes>

    <remarks></remarks>

    <ownerSignature>
        <signatureName>Jeffrey M. Schweitzer</signatureName>
        <signatureDate>2010-02-08</signatureDate>
    </ownerSignature>
</ownershipDocument>
